package com.yanqu.road.server.cmd.activity.feast.pvp;

import com.yanqu.road.entity.activity.feast.config.ShanHeFeastConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ShanHeFeastProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.feast.ShanHeFeastMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_SHAN_HE_FEAST_PVP_PING, desc = "心跳包")
public class FeastPvpPingCmd extends AbstractCommand {


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ShanHeFeastProto.FeastPvpPingReqMsg reqMsg = ShanHeFeastProto.FeastPvpPingReqMsg.parseFrom(packet.getBytes());
        //获取活动配置
        ShanHeFeastConfig feastConfig = ShanHeFeastMgr.getConfig();
        if (feastConfig == null || !ActivityMgr.activityInTime(feastConfig.getActivityInfo())) {
            ret = GameErrorCode.E_DAOMU_ACTIVITY_NOT_EXIST;
            return;
        }
        // 直接上跨服
        player.sendPacket(Protocol.C_CROSS_SHAN_HE_FEAST_PVP_PING, reqMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
